package 实验八;

import java.util.Scanner;


public class Task {
    public static void main(String[] args){

        Scanner in = new Scanner(System.in);
        int number = Integer.parseInt(in.next());
        int [] num = new int [number];
        System.out.println("请输入数组");
        for(int i=0;i<number;i++){
            num[i] = (int)in.nextInt();
        }
        int sum ;
        int max = Integer.MIN_VALUE;
        for(int i=0;i<number;i++){
            sum=0;
            for(int j=i;j<number;j++){
                sum+=num[j];
                if(sum>max)
                    max=sum;
            }
        }
        System.out.println("最大子数组之和为");

        System.out.println(max);
    }
}

